import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDMissionMainLine {
	/**ID*/
	id,
	/**总任务类型*/
	missionId,
	/**任务1*/
	missionId_1,
	/**任务2*/
	missionId_2,
	/**任务3*/
	missionId_3,
	/**任务4*/
	missionId_4,
	/**任务5*/
	missionId_5,

	/**枚举数量*/
	EnumCount
}



export class CDMissionMainLine{
	/**ID*/
	public id: number;
	/**总任务类型*/
	public missionId: number;
	/**任务1*/
	public missionId_1: number;
	/**任务2*/
	public missionId_2: number;
	/**任务3*/
	public missionId_3: number;
	/**任务4*/
	public missionId_4: number;
	/**任务5*/
	public missionId_5: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDMissionMainLine.id: return this.id;
			case E_CDMissionMainLine.missionId: return this.missionId;
			case E_CDMissionMainLine.missionId_1: return this.missionId_1;
			case E_CDMissionMainLine.missionId_2: return this.missionId_2;
			case E_CDMissionMainLine.missionId_3: return this.missionId_3;
			case E_CDMissionMainLine.missionId_4: return this.missionId_4;
			case E_CDMissionMainLine.missionId_5: return this.missionId_5;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDMissionMainLine.id: this.id = v; break;
			case E_CDMissionMainLine.missionId: this.missionId = v; break;
			case E_CDMissionMainLine.missionId_1: this.missionId_1 = v; break;
			case E_CDMissionMainLine.missionId_2: this.missionId_2 = v; break;
			case E_CDMissionMainLine.missionId_3: this.missionId_3 = v; break;
			case E_CDMissionMainLine.missionId_4: this.missionId_4 = v; break;
			case E_CDMissionMainLine.missionId_5: this.missionId_5 = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDMissionMainLine> = new HashMap<number, CDMissionMainLine>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDMissionMainLine[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDMissionMainLine();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].missionId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missionId_1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missionId_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missionId_3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missionId_4 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missionId_5 = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDMissionMainLine{
		return this.datas ? this.datas.get(id) : null;
	}
}
